import { SystemSettingDao } from "../../gm_server/dao/SystemSettingDao";
import { WebVersionModel } from "../../web_server/model/WebVersionModel";
import { GameConfig } from "../config/GameConfig";
import { Logger } from "../engine/utils/Logger";

export class SystemSettingModel {

    public static instance: SystemSettingModel = new SystemSettingModel();

    public notice: string = "test"
    public customer: string = "test"
    public download: string = "test"
    public newusersend:number = 0

    public async init() {
        let results: Array<object> = await SystemSettingDao.get_all_system_setting()
        // Logger.log("results====", results)
        for (let i = 0; i < results.length; i++) {
            if (results[i]["setting_key"] == GameConfig.System_Setting.notice) {
                this.notice = results[i]["setting_value"]
            }
            else if (results[i]["setting_key"] == GameConfig.System_Setting.customer) {
                this.customer = results[i]["setting_value"]
            }
            else if (results[i]["setting_key"] == GameConfig.System_Setting.download) {
                this.download = results[i]["setting_value"]
            }
            else if (results[i]["setting_key"] == GameConfig.System_Setting.newusersend) {
                this.newusersend = parseInt(results[i]["setting_value"])
            }
        }
        WebVersionModel.android_download_url = this.download
        WebVersionModel.ios_download_url = this.download
        // Logger.log("SystemSettingModel====", SystemSettingModel.instance)

    }


}